home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWCommon / Include / FWPriStr.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  2.7 KB  |  106 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPriStr.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPRISTR_H
  11. #define FWPRISTR_H
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. #include <stddef.h>
  18.  
  19. #ifdef FW_BUILD_WIN
  20. #include <ctype.h>
  21.     // Include for toupper, tolower, isspace
  22. #endif
  23.  
  24. #if FW_LIB_EXPORT_PRAGMAS
  25. #pragma lib_export on
  26. #endif
  27.  
  28. size_t FW_FUNC_ATTR FW_PrimitiveStringLength(const char * p);
  29.     // Returns the length of string p.
  30.     
  31. int FW_FUNC_ATTR FW_PrimitiveStringEqual(const char *p1, const char *p2);
  32.     // Compares string p1 to p2. Returns 1 if equal and 0 if false.
  33.     
  34. void FW_FUNC_ATTR FW_PrimitiveStringCopy(const char *source, char *destination);
  35.     // Copies string source to string destination.
  36.     // Assumes that destination is large enough!
  37.         
  38. void FW_FUNC_ATTR FW_PrimitiveStringCatenate(const char *source, char *destination);
  39.     // Appends string source onto string destination.
  40.     // Assumes that destination is large enough!
  41.         
  42. FW_FUNC_ATTR char * FW_PrimitiveStringFindCharacter(const char *source, char c);
  43.     // Return pointer to first occurrence of c in source or NULL if not present.
  44.     
  45. char FW_FUNC_ATTR FW_PrimitiveCharacterToUpper(char c);
  46.     // Return character c converted to upper case.
  47.     
  48. char FW_FUNC_ATTR FW_PrimitiveCharacterToLower(char c);
  49.     // Return character c converted to lower case.
  50.  
  51. char FW_FUNC_ATTR FW_PrimitiveCharacterIsSpace(char c);
  52.     // Returns non-zero if character is space, tab, carriage return, or newline.
  53.  
  54. //========================================================================================
  55. // FWPriStr.h inlines
  56. //========================================================================================
  57.  
  58. inline char FW_PrimitiveCharacterToUpper(char c)
  59. {
  60. #ifdef FW_BUILD_MAC
  61.     if (c >= 'a' && c <= 'z')
  62.         return (c - 'a' + 'A');
  63.     else
  64.         return (c);
  65. #endif
  66.  
  67. // Use the standard library version to take advantage of locale information
  68. #ifdef FW_BUILD_WIN
  69.     return toupper(c);
  70. #endif
  71. }
  72.  
  73.  
  74. inline char FW_PrimitiveCharacterToLower(char c)
  75. {
  76. #ifdef FW_BUILD_MAC
  77.     if (c >= 'A' && c <= 'Z')
  78.         return (c + 'a' - 'A');
  79.     else
  80.         return (c);
  81. #endif
  82.  
  83. // Use the standard library version to take advantage of locale information
  84. #ifdef FW_BUILD_WIN
  85.     return tolower(c);
  86. #endif
  87. }
  88.  
  89. inline char FW_PrimitiveCharacterIsSpace(char c)
  90. {
  91. #ifdef FW_BUILD_MAC
  92.     return ((c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f') ? c : 0);
  93. #endif
  94.  
  95. // Use the standard library version to take advantage of locale information
  96. #ifdef FW_BUILD_WIN
  97.     return isspace(c);
  98. #endif
  99. }
  100.  
  101. #if FW_LIB_EXPORT_PRAGMAS
  102. #pragma lib_export off
  103. #endif
  104.  
  105. #endif
  106.